import "./assets/main.css";

import { createApp } from "vue";

import ElementPlus from "element-plus";
import "element-plus/dist/index.css";

// 开发环境使用mockjs拦截axios请求，生产环境使用真实的数据接口将该行代码注释即可
// import "@/mock/index.js"

import App from "./App.vue";
import router from "./router";
import i18n from "./lang/index";
import { createPinia } from "pinia";
import piniaPluginPersistedstate from "pinia-plugin-persistedstate";


// markdown 展示
import VMdPreview from '@kangc/v-md-editor/lib/preview';
import '@kangc/v-md-editor/lib/style/preview.css';
// VuePress主题以及样式（这里也可以选择github主题）
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
// emoji
import createEmojiPlugin from '@kangc/v-md-editor/lib/plugins/emoji/index';
import '@kangc/v-md-editor/lib/plugins/emoji/emoji.css';
// mermaid
import createMermaidPlugin from '@kangc/v-md-editor/lib/plugins/mermaid/cdn';
import '@kangc/v-md-editor/lib/plugins/mermaid/mermaid.css';
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';
// 快速复制代码
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';


// Prism
import Prism from 'prismjs';
// 代码高亮
import 'prismjs/components/prism-json';



const app = createApp(App); 

// Vue3中 关闭 vue warn
app.config.warnHandler = () => {}; // 或者任何其他你想要的自定义处理函数

// 全局导入的方式，最后app打包时会比较大，太大会影响性能
// import * as ElementPlusIconsVue from '@element-plus/icons-vue'
// for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
//     app.component(key, component)
// }

// element-plus
app.use(ElementPlus);

// pinia
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
// 重写一个$reset 方法
pinia.use(({ store }) => {
  const initialState = JSON.parse(JSON.stringify(store.$state));
  store.$reset = () => {
    store.$patch(initialState);
  };
});

app.use(pinia);

app.use(router);

// i18n国际化配置
app.use(i18n);

// markdown展示   
// 选择使用主题
VMdPreview.use(vuepressTheme, {
  Prism,
});
// VMdPreview.use(createEmojiPlugin());
VMdPreview.use(createMermaidPlugin());
VMdPreview.use(createLineNumbertPlugin());
VMdPreview.use(createCopyCodePlugin());

app.use(VMdPreview);


app.mount("#app");
